package com.tronapi.c.model;

import java.util.HashMap;
import java.util.Map;

public class R {

    public static Map<String, Object> success(Object obj) {
        return info(obj, null, "200", true);
    }

    public static Map<String, Object> error(String errorMsg, String code) {
        return info(null, errorMsg, code, false);
    }

    public static Map<String, Object> error(String errorMsg) {
        return info(null, errorMsg, "500", false);
    }

    private static Map<String, Object> info(Object obj, String errorMsg, String code, boolean success) {
        Map<String, Object> res = new HashMap<>(4);
        res.put("success", success);
        res.put("data", obj);
        res.put("errorMsg", errorMsg);
        res.put("code", code);
        return res;
    }
}
